package com.ado.abyss.core.manager.impl;

import com.ado.abyss.core.dal.dao.SysDeptMapper;
import com.ado.abyss.core.dal.model.SysDept;
import com.ado.abyss.core.manager.SysDeptManager;
import com.ado.abyss.core.utils.JudgeResultUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author adonais
 * @date 2020/7/9
 * @description SysDeptManagerImpl
 **/
@Service(value = "sysDeptManager")
public class SysDeptManagerImpl extends ServiceImpl<SysDeptMapper, SysDept> implements SysDeptManager {

    @Autowired
    private SysDeptMapper sysDeptMapper ;

    @Override
    public List<SysDept> findAll() {
        return sysDeptMapper.findAll();
    }

    @Override
    @Transactional
    public boolean saveDept(SysDept record) {
        boolean flag = false ;
        int result = sysDeptMapper.saveDept(record) ;
        if(result == 1) {
            flag = true ;
        }
        return flag;
    }

    @Override
    @Transactional
    public boolean deleteById(Long id) {
        boolean flag = false ;
        int result = sysDeptMapper.deleteByPrimaryKey(id) ;
        if(result == 1) {
            flag = true ;
        }
        return flag;
    }

    @Override
    @Transactional
    public boolean deleteByIds(List<Long> list) {
        boolean flag = false ;
        int result = sysDeptMapper.deleteByIds(list) ;
        flag = JudgeResultUtil.judgeReturn(result) ;
        return flag;
    }

    @Override
    public SysDept findById(Long id) {
        SysDept sysDept = sysDeptMapper.selectByPrimaryKey(id) ;
        return sysDept;
    }
}
